package com.etop.weibo.beans;

import java.sql.Timestamp;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * <p>既可评论微博，又可评论评论</p>
 * <p>userId----u_id</p>
 * <p>sayId---s_id  default = -1</p>
 * <p>commentId----c_id  default = -1</p>
 * <p>如果是评论微博的，则commentId=-1</p>
 * @author jansing lz_jansing@163.com
 */
@Entity
@Table(name = "t_comment")
public class Comment {

    private int id;
    private int userId;
    private int sayId;
    private int commentId;
    private int praise;
    private String what;
    private Date createTime;
    //为list服务的字段
    //如果评论微博，则listTime=createTime
    //如果评论评论，则listTime=CommentDao.get(commentId).createTime
    //调用list方法，根据这个值来排序
    //实现对同一条微博的评论大排序，对同一条评论的评论小排序
    private Date listTime;

    public Comment() {
    }

    public Comment(int userId, int sayId, int commentId, String what, int praise, Date createTime, Date listTime) {
        this();
        this.userId = userId;
        this.sayId = sayId;
        this.commentId = commentId;
        this.what = what;
        this.praise = praise;
        this.createTime = createTime;
        this.listTime = listTime;
    }

    public Comment(int id, int userId, int sayId, int commentId, String what, int praise,
                        Date createTime, Date listTime) {
        this.id = id;
        this.userId = userId;
        this.sayId = sayId;
        this.commentId = commentId;
        this.what = what;
        this.praise = praise;
        this.createTime = createTime;
        this.listTime = listTime;
    }

    @Id
    @GeneratedValue
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name = "u_id")
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    //设置默认值，-1表示不是对此评论
    @Column(name = "s_id", nullable=false, columnDefinition="int default -1")
    public int getSayId() {
        return sayId;
    }

    public void setSayId(int sayId) {
        this.sayId = sayId;
    }

    //设置默认值，-1表示不是对此评论
    @Column(name = "c_id", nullable=false, columnDefinition="int default -1")
    public int getCommentId() {
        return commentId;
    }

    public void setCommentId(int commentId) {
        this.commentId = commentId;
    }

    @Column(name = "what")
    public String getWhat() {
        return what;
    }

    public void setWhat(String what) {
        this.what = what;
    }

    @Column(name = "praise")
    public int getPraise() {
        return praise;
    }

    public void setPraise(int praise) {
        this.praise = praise;
    }

    @Column(name = "create_time")
    @Temporal(value = TemporalType.TIMESTAMP)
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Column(name="list_time")
    @Temporal(value=TemporalType.TIMESTAMP)
    public Date getListTime() {
        return listTime;
    }

    public void setListTime(Date listTime) {
        this.listTime = listTime;
    }

    
}
